/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;

/**
 *
 * @author fr4om
 */
public class PictureContainer {

    private static PictureContainer instance;
    private ArrayList<BufferedImage> pictures;

    public enum PictureType {

        AND2, AND3, AND4, AND5,
        OR2, OR3, OR4, OR5,
        COMPOSITE, DISPLAYOFF, DISPLAYON,
        GENERATOR, INVERTER, OSCILLOSCOPE,
        SWITCHOFF, SWITCHON
    }

    private PictureContainer() {
        pictures = new ArrayList<BufferedImage>();

        try {
            pictures.add(ImageIO.read(new File("pic\\and2.bmp")));
            pictures.add(ImageIO.read(new File("pic\\and3.bmp")));
            pictures.add(ImageIO.read(new File("pic\\and4.bmp")));
            pictures.add(ImageIO.read(new File("pic\\and5.bmp")));
            pictures.add(ImageIO.read(new File("pic\\composite.bmp")));
            pictures.add(ImageIO.read(new File("pic\\displayoff.bmp")));
            pictures.add(ImageIO.read(new File("pic\\displayon.bmp")));
            pictures.add(ImageIO.read(new File("pic\\generator.bmp")));
            pictures.add(ImageIO.read(new File("pic\\inverter.bmp")));
            pictures.add(ImageIO.read(new File("pic\\or2.bmp")));
            pictures.add(ImageIO.read(new File("pic\\or3.bmp")));
            pictures.add(ImageIO.read(new File("pic\\or4.bmp")));
            pictures.add(ImageIO.read(new File("pic\\or5.bmp")));
            pictures.add(ImageIO.read(new File("pic\\oscilloscope.bmp")));
            pictures.add(ImageIO.read(new File("pic\\switchoff.bmp")));
            pictures.add(ImageIO.read(new File("pic\\switchon.bmp")));
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }
    }

    public static PictureContainer getInstance() {
        if (instance == null) {
            instance = new PictureContainer();
        }

        return instance;
    }

    public BufferedImage loadPicture(PictureType pictureType) {
        switch (pictureType) {
            case AND2:
                return pictures.get(0);
            case AND3:
                return pictures.get(1);
            case AND4:
                return pictures.get(2);
            case AND5:
                return pictures.get(3);
            case COMPOSITE:
                return pictures.get(4);
            case DISPLAYOFF:
                return pictures.get(5);
            case DISPLAYON:
                return pictures.get(6);
            case GENERATOR:
                return pictures.get(7);
            case INVERTER:
                return pictures.get(8);
            case OR2:
                return pictures.get(9);
            case OR3:
                return pictures.get(10);
            case OR4:
                return pictures.get(11);
            case OR5:
                return pictures.get(12);
            case OSCILLOSCOPE:
                return pictures.get(13);
            case SWITCHOFF:
                return pictures.get(14);
            case SWITCHON:
                return pictures.get(15);
            default:
                return null;
        }
    }
}
